package com.atguigu.lease.common.ExceptionHandler;

import com.atguigu.lease.common.exceptions.LeaseException;
import com.atguigu.lease.common.result.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandlers {
    @ExceptionHandler(Exception.class)
    public Result exception(Exception e) {
        e.printStackTrace(); //打印异常信息
        return Result.fail();
    }
    @ExceptionHandler(LeaseException.class)
    public Result LeaseException(LeaseException e) {
        e.printStackTrace(); //打印异常信息
        return Result.build(e.getCode(),e.getMessage());
    }
}
